package com.dxx.cloud.admin.service.qiniu;

import com.dxx.cloud.admin.module.response.qiniu.QiNiuTokenResponse;
import com.qiniu.util.Auth;
import org.springframework.stereotype.Service;

@Service
public class QiniuService {

    private String accessKey = "RPAwJZUv4x3vlLdGMatQvV7G9QCJZj6MReV63Ndo";
    private String secretKey = "aUwrpCh_v-4IMzkOUP-FNNGJZXXB_T_rRhSm9lSK";
    private String bucket = "laoz";
    private static final String urlPrefix = "https://qiniu.dadaozhixing.top/";

    public QiNiuTokenResponse generateToken(){
        Auth auth = Auth.create(accessKey,secretKey);
        String token = auth.uploadToken(bucket);
        QiNiuTokenResponse response = new QiNiuTokenResponse();
        response.setToken(token);
        response.setPrefixUrl(urlPrefix);
        return response;
    }

}
